#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
constexpr int maxn = 100000 + 10;
i64 d[maxn], v[maxn], a[maxn];
int p[maxn];
i64 calc(int i, i64 p)
{
    return v[i] * v[i] + 2 * a[i] * (p - d[i]);
}
struct cmp
{
    bool operator()(const pii& a, const pii& b) const
    {
        return a.second == b.second ? a.first > b.first : a.second < b.second;
    }
};
void solve()
{
    int n, m;
    i64 L, V;
    cin >> n >> m >> L >> V;
    for (int i=1;i<=n;++i) cin >> d[i] >> v[i] >> a[i];
    for (int i=1;i<=m;++i) cin >> p[i];
    vector<pii> c;
    for (int i=1;i<=n;++i)
    {
        if (a[i] == 0)
        {
            if (v[i] <= V) continue;
            int l = 1, r = m + 1;
            while (l < r)
            {
                int x = (l + r) >> 1;
                if (p[x] < d[i]) l = x + 1;
                else r = x;
            }
            if (l <= m) c.emplace_back(pii(l, m));
        }
        if (a[i] > 0)
        {
            int l = 1, r = m + 1;
            while (l < r)
            {
                int x = (l + r) >> 1;
                if (p[x] < d[i]) l = x + 1;
                else
                {
                    if (V * V < calc(i, p[x])) r = x;
                    else l = x + 1;
                }
            }
            if (l <= m) c.emplace_back(pii(l, m));
        }
        if (a[i] < 0)
        {
            if (v[i] <= V) continue;
            int l = 1, r = m + 1;
            while (l < r)
            {
                int x = (l + r) >> 1;
                if (p[x] < d[i]) l = x + 1;
                else r = x;
            }
            if (l > m) continue;
            if (calc(i, p[l]) <= V * V) continue;
            int st = l;
            r = m + 1;
            while (l < r)
            {
                int x = (l + r) >> 1;
                if (calc(i, p[x]) > V * V) l = x + 1;
                else r = x;
            }
            c.emplace_back(pii(st, r - 1));
        }
    }
    cout << c.size() << ' ';
    sort(c.begin(), c.end(), cmp());
    int lst = 0, ans = 0;
    for (auto i : c)
    {
        int l = i.first, r = i.second;
        if (lst < l) lst = r, ++ans;
    }
    cout << m - ans << '\n';
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}